home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / fs / fsNameOps.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  10.5 KB  |  293 lines

  1. /*
  2.  * fsNameOps.h --
  3.  *
  4.  *    Definitions for pathname related operations.  These data structures
  5.  *    define the file system's naming interface.  This is used internally,
  6.  *    for network RPCs, and for the interface to pseudo-file-systems.
  7.  *
  8.  * Copyright 1986 Regents of the University of California
  9.  * All rights reserved.
  10.  *
  11.  *
  12.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/fs/fsNameOps.h,v 9.5 91/09/10 18:22:38 rab Exp $ SPRITE (Berkeley)
  13.  */
  14.  
  15. #ifndef _FSNAMEOPS
  16. #define _FSNAMEOPS
  17.  
  18. /*
  19.  *
  20.  *    There are twp operation switch tables defined here.  (See fsOpTable.c
  21.  *    for their initialization.)
  22.  *    1. The DOMAIN table used for naming operations like OPEN or REMOVE_DIR.
  23.  *        These operations take file names as arguments and have to
  24.  *        be pre-processed by the prefix table module in order to
  25.  *        chose the correct domain type and server.
  26.  *    2. The ATTR table is used when getting/setting attributes when
  27.  *        starting with an open stream (not with a file name).  This
  28.  *        is keyed on the type of the nameFileID in the stream.
  29.  *
  30.  * Name Domain Types:
  31.  *
  32.  *    FS_LOCAL_DOMAIN        The file is stored locally.
  33.  *    FS_REMOTE_SPRITE_DOMAIN    The file is stored on a Sprite server.
  34.  *    FS_PSEUDO_DOMAIN    The file system is implemented by
  35.  *                a user-level server process
  36.  *    FS_NFS_DOMAIN        The file is stored on an NFS server.
  37.  *
  38.  */
  39.  
  40. #define FS_LOCAL_DOMAIN            0
  41. #define FS_REMOTE_SPRITE_DOMAIN        1
  42. #define FS_PSEUDO_DOMAIN        2
  43. #define FS_NFS_DOMAIN            3
  44.  
  45. #define FS_NUM_DOMAINS            4
  46.  
  47. /*
  48.  * DOMAIN SWITCH
  49.  * Domain specific operations that operate on file names for lookup.
  50.  * Naming operations are done through Fsprefix_LookupOperation, which uses
  51.  * the prefix table to choose the domain type and the server for the name.
  52.  * It then branches through the fs_DomainLookup table to complete the operation.
  53.  * The arguments to these operations are documented in fsNameOps.h
  54.  * because they are collected into structs (declared in fsNameOps.h)
  55.  * and passed through Fsprefix_LookupOperation() to domain-specific routines.
  56.  */
  57.  
  58. #define    FS_DOMAIN_IMPORT        0
  59. #define    FS_DOMAIN_EXPORT        1
  60. #define    FS_DOMAIN_OPEN            2
  61. #define    FS_DOMAIN_GET_ATTR        3
  62. #define    FS_DOMAIN_SET_ATTR        4
  63. #define    FS_DOMAIN_MAKE_DEVICE        5
  64. #define    FS_DOMAIN_MAKE_DIR        6
  65. #define    FS_DOMAIN_REMOVE        7
  66. #define    FS_DOMAIN_REMOVE_DIR        8
  67. #define    FS_DOMAIN_RENAME        9
  68. #define    FS_DOMAIN_HARD_LINK        10
  69.  
  70. #define    FS_NUM_NAME_OPS            11
  71.  
  72. extern    ReturnStatus (*fs_DomainLookup[FS_NUM_DOMAINS][FS_NUM_NAME_OPS])();
  73.  
  74. /*
  75.  * ATTRIBUTE SWITCH
  76.  * A switch is used to get to the name server in set/get attributesID,
  77.  * which take an open stream.  The stream refereneces a nameFileID, and
  78.  * this switch is keyed on the nameFileID.type (i.e. local or remote file).
  79.  */
  80.  
  81. typedef struct Fs_AttrOps {
  82.     ReturnStatus    (*getAttr) _ARGS_((Fs_FileID *fileIDPtr, int clientID,
  83.                         Fs_Attributes *attrPtr));
  84.  
  85.     ReturnStatus    (*setAttr) _ARGS_((Fs_FileID *fileIDPtr, 
  86.                       Fs_Attributes *attrPtr, 
  87.                       Fs_UserIDs *idPtr, int flags));
  88. } Fs_AttrOps;
  89.  
  90. extern Fs_AttrOps fs_AttrOpTable[];
  91.  
  92.  
  93. /*
  94.  * The arguments and results of the various lookup operations have to
  95.  * be packaged into a struct so they can be passed through Fsprefix_LookupOperation()
  96.  * and into the domain specific lookup routine.  The following typedefs
  97.  * are for those arguments and results.
  98.  *
  99.  * Pseudo-file-systems:  These structures are also used in the interface
  100.  *    to pseudo-file-system servers.  See <dev/pfs.h>
  101.  */
  102.  
  103. /*
  104.  *     Fs_OpenArgs are used for the DOMAIN_OPEN, DOMAIN_GET_ATTR,
  105.  *    DOMAIN_SET_ATTR, DOMAIN_MAKE_DIR and DOMAIN_MAKE_DEVICE operations.
  106.  *    (Actually, Fs_MakeDeviceArgs & Fs_SetAttrArgs embed Fs_OpenArgs)
  107.  *
  108.  *    The arguments for open specify the starting point of the lookup,
  109.  *    then the root file of the lookup domain, then other parameters
  110.  *    identifying the client and its intended use of the file.
  111.  *
  112.  *    The results of the open fileIDs for the I/O server, the name server,
  113.  *    and the top-level stream to the file.  There is also some data that
  114.  *    is specific to the file type
  115.  *
  116.  */
  117.  
  118. typedef struct Fs_OpenArgs {
  119.     Fs_FileID    prefixID;    /* File ID from prefix handle, MUST BE FIRST */
  120.     Fs_FileID    rootID;        /* File ID of root.  MUST FOLLOW prefix ID.
  121.                  * Used to trap ".." past the root. */
  122.     int        useFlags;    /* Flags defined in fs.h */
  123.     int        permissions;    /* Permission bits for created files.  Already
  124.                  * reflects per-process permission mask */
  125.     int        type;        /* Used to contrain open to a specific type */
  126.     int        clientID;    /* True Host ID of client doing the open */
  127.     int        migClientID;    /* Logical host ID if migrated (the home node)*/
  128.     Fs_UserIDs    id;        /* User and group IDs */
  129. } Fs_OpenArgs;
  130.  
  131. typedef struct Fs_OpenResults {
  132.     Fs_FileID    ioFileID;    /* FileID used to get to I/O server.  This is
  133.                  * set by the name server, although the I/O
  134.                  * server has the right to modify the major
  135.                  * and minor numbers */
  136.     Fs_FileID    streamID;    /* File ID of the stream being opened */
  137.     Fs_FileID    nameID;        /* FileID used to get to the name of the file.*/
  138.     int        dataSize;    /* Size of extra streamData */
  139.     ClientData    streamData;    /* Pointer to stream specific extra data */
  140. } Fs_OpenResults;
  141.  
  142. /*
  143.  * Fs_LookupArgs are used for the DOMAIN_REMOVE and DOMAIN_REMOVE_DIR
  144.  * operations.  Also, Fs_2PathParams embeds Fs_LookupArgs.
  145.  */
  146. typedef struct Fs_LookupArgs {
  147.     Fs_FileID prefixID;    /* FileID of the prefix, MUST BE FIRST */
  148.     Fs_FileID rootID;    /* FileID of the root, MUST FOLLOW prefixID */
  149.     int useFlags;    /* FS_EXECUTE or FS_RENAME */
  150.     Fs_UserIDs id;    /* User and group IDs */
  151.     int clientID;    /* True HostID, needed to expand $MACHINE */
  152.     int migClientID;    /* Logical host ID if migrated (the home node) */
  153. } Fs_LookupArgs;
  154.  
  155. /*
  156.  * FS_DOMAIN_GET_ATTR results.
  157.  */
  158. typedef struct Fs_GetAttrResults {
  159.     Fs_FileID        *fileIDPtr;    /* File ID that indicates I/O server */
  160.     Fs_Attributes    *attrPtr;    /* Returned results */
  161. } Fs_GetAttrResults;
  162.  
  163. /*
  164.  * Rpc storage reply parameter for both redirected and unredirected calls.
  165.  */
  166. typedef    union    Fs_GetAttrResultsParam {
  167.     int    prefixLength;
  168.     struct    AttrResults {
  169.     Fs_FileID    fileID;
  170.     Fs_Attributes    attrs;
  171.     } attrResults;
  172. } Fs_GetAttrResultsParam;
  173.  
  174. /*
  175.  * FS_DOMAIN_SET_ATTR arguments.
  176.  */
  177. typedef struct Fs_SetAttrArgs {
  178.     Fs_OpenArgs        openArgs;
  179.     Fs_Attributes    attr;
  180.     int            flags;    /* Set attr flags defined in user/fs.h */
  181. } Fs_SetAttrArgs;
  182.  
  183. /*
  184.  * FS_DOMAIN_MAKE_DEVICE arguments and results.
  185.  */
  186. typedef struct Fs_MakeDeviceArgs {
  187.     Fs_OpenArgs open;
  188.     Fs_Device device;
  189. } Fs_MakeDeviceArgs;
  190.  
  191. /*
  192.  * FS_DOMAIN_RENAME and FS_DOMAIN_HARD_LINK
  193.  */
  194. typedef struct Fs_2PathParams {
  195.     Fs_LookupArgs    lookup;
  196.     Fs_FileID        prefixID2;
  197. } Fs_2PathParams;
  198.  
  199. typedef struct Fs_2PathData {
  200.     char        path1[FS_MAX_PATH_NAME_LENGTH];
  201.     char        path2[FS_MAX_PATH_NAME_LENGTH];
  202. } Fs_2PathData;
  203.  
  204. typedef struct Fs_2PathReply {
  205.     int        prefixLength;    /* Length of returned prefix on re-direct */
  206.     Boolean    name1ErrorP;    /* TRUE if the error returned, which is either
  207.                  * a re-direct or stale-handle, applies to
  208.                  * the first of the two pathnames, FALSE if
  209.                  * it applies to the second pathname */
  210. } Fs_2PathReply;
  211.  
  212. /*
  213.  * All pathname operations may potentially return new prefix information
  214.  * from the server, or redirected lookups.
  215.  */
  216. typedef struct Fs_RedirectInfo {
  217.     int    prefixLength;        /* The length of the prefix embedded in
  218.                  * fileName.  This is used when a server hits
  219.                  * a remote link and has to return a new file
  220.                  * name plus an indication of a new prefix. */
  221.     char fileName[FS_MAX_PATH_NAME_LENGTH];    /* A new file name.  Returned
  222.                  * from the server when its lookup is about
  223.                  * to leave its domain. */
  224. } Fs_RedirectInfo;
  225.  
  226. typedef struct Fs_2PathRedirectInfo {
  227.     int name1ErrorP;        /* TRUE if redirection or other error applies
  228.                  * to the first pathname, FALSE if the error
  229.                  * applies to second pathname, or no error */
  230.     int    prefixLength;        /* The length of the prefix embedded in
  231.                  * fileName.  This is used when a server hits
  232.                  * a remote link and has to return a new file
  233.                  * name plus an indication of a new prefix. */
  234.     char fileName[FS_MAX_PATH_NAME_LENGTH];    /* A new file name.  Returned
  235.                  * from the server when its lookup is about
  236.                  * to leave its domain. */
  237. } Fs_2PathRedirectInfo;
  238.  
  239.  
  240. /*
  241.  * Table of name lookup routine maintained by each domain type.
  242.  */
  243. typedef struct Fs_DomainLookupOps {
  244.      ReturnStatus (*import) _ARGS_((char *prefix, int serverID, 
  245.             Fs_UserIDs *idPtr, int *domainTypePtr,
  246.             Fs_HandleHeader **hdrPtrPtr));
  247.      ReturnStatus (*export) _ARGS_((Fs_HandleHeader *hdrPtr, int clientID,
  248.             Fs_FileID *ioFileIDPtr, int *dataSizePtr, 
  249.             ClientData *clientDataPtr));
  250.      ReturnStatus (*open) _ARGS_((Fs_HandleHeader *prefixHandlePtr,
  251.             char *relativeName, Address argsPtr, Address resultsPtr, 
  252.             Fs_RedirectInfo **newNameInfoPtrPtr));
  253.      ReturnStatus (*getAttrPath) _ARGS_((Fs_HandleHeader *prefixHandlePtr,
  254.             char *relativeName, Address argsPtr, Address resultsPtr,
  255.             Fs_RedirectInfo **newNameInfoPtrPtr));
  256.      ReturnStatus (*setAttrPath) _ARGS_((Fs_HandleHeader *prefixHandlePtr,
  257.             char *relativeName, Address argsPtr, Address resultsPtr,
  258.             Fs_RedirectInfo **newNameInfoPtrPtr));
  259.      ReturnStatus (*makeDevice) _ARGS_((Fs_HandleHeader *prefixHandle, 
  260.             char *relativeName, Address argsPtr, Address resultsPtr,
  261.             Fs_RedirectInfo **newNameInfoPtrPtr));
  262.      ReturnStatus (*makeDir) _ARGS_((Fs_HandleHeader *prefixHandle, 
  263.             char *relativeName, Address argsPtr, Address resultsPtr, 
  264.             Fs_RedirectInfo **newNameInfoPtrPtr));
  265.      ReturnStatus (*remove) _ARGS_((Fs_HandleHeader *prefixHandle, 
  266.             char *relativeName, Address argsPtr, Address resultsPtr, 
  267.             Fs_RedirectInfo **newNameInfoPtrPtr));
  268.      ReturnStatus (*removeDir) _ARGS_((Fs_HandleHeader *prefixHandle, 
  269.             char *relativeName, Address argsPtr, Address resultsPtr, 
  270.             Fs_RedirectInfo **newNameInfoPtrPtr));
  271.      ReturnStatus (*rename) _ARGS_((Fs_HandleHeader *prefixHandle1, 
  272.             char *relativeName1, Fs_HandleHeader *prefixHandle2, 
  273.             char *relativeName2, Fs_LookupArgs *lookupArgsPtr, 
  274.             Fs_RedirectInfo **newNameInfoPtrPtr, 
  275.             Boolean *name1ErrorPtr));
  276.      ReturnStatus (*hardLink) _ARGS_((Fs_HandleHeader *prefixHandle1, 
  277.             char *relativeName1, Fs_HandleHeader *prefixHandle2,
  278.             char *relativeName2, Fs_LookupArgs *lookupArgsPtr, 
  279.             Fs_RedirectInfo **newNameInfoPtrPtr, 
  280.             Boolean *name1ErrorPtr));
  281. } Fs_DomainLookupOps;
  282.  
  283.  
  284. /*
  285.  * Forward references.
  286.  */
  287. extern void Fs_SetIDs _ARGS_((Proc_ControlBlock *procPtr, Fs_UserIDs *idPtr));
  288. extern void Fs_InstallDomainLookupOps _ARGS_((int domainType, 
  289.         Fs_DomainLookupOps *nameLookupOpsPtr, 
  290.         Fs_AttrOps *attrOpTablePtr));
  291.  
  292. #endif _FSNAMEOPS
  293.